
namespace ctsu.BaseForms
{
	public class FormSearchBase : System.Windows.Forms.Form
	{
		public int SelectedID = -1;
		public ISearchController Controller;

		public System.Windows.Forms.ListView SearchResults;
		public System.Windows.Forms.ComboBox SearchFields;
		public System.Windows.Forms.TextBox Criteria;
		protected System.Windows.Forms.Button btnOK;
		protected System.Windows.Forms.Button btnCancel;
		public System.Windows.Forms.RadioButton Ascending;
		public System.Windows.Forms.RadioButton Descending;

		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnRun;
		protected System.Windows.Forms.Label lblOrder;
		public System.Windows.Forms.Button btnApply;

		private System.ComponentModel.Container components = null;

		public FormSearchBase()
		{
			InitializeComponent();

		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose(disposing);
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FormSearchBase));
			this.label4 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnOK = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.SearchResults = new System.Windows.Forms.ListView();
			this.Criteria = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.SearchFields = new System.Windows.Forms.ComboBox();
			this.btnRun = new System.Windows.Forms.Button();
			this.lblOrder = new System.Windows.Forms.Label();
			this.Ascending = new System.Windows.Forms.RadioButton();
			this.Descending = new System.Windows.Forms.RadioButton();
			this.btnApply = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(8, 64);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(56, 16);
			this.label4.TabIndex = 22;
			this.label4.Text = "Criteria:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 44);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(240, 24);
			this.label3.TabIndex = 21;
			this.label3.Text = "(Leave criteria blank to return all rows)";
			// 
			// btnCancel
			// 
			this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnCancel.Image = ((System.Drawing.Image)(resources.GetObject("btnCancel.Image")));
			this.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnCancel.Location = new System.Drawing.Point(168, 369);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(80, 23);
			this.btnCancel.TabIndex = 20;
			this.btnCancel.Text = "&Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// btnOK
			// 
			this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnOK.Image = ((System.Drawing.Image)(resources.GetObject("btnOK.Image")));
			this.btnOK.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnOK.Location = new System.Drawing.Point(72, 369);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(80, 23);
			this.btnOK.TabIndex = 19;
			this.btnOK.Text = "&OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 96);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(96, 16);
			this.label2.TabIndex = 18;
			this.label2.Text = "Search results:";
			// 
			// SearchResults
			// 
			this.SearchResults.Activation = System.Windows.Forms.ItemActivation.TwoClick;
			this.SearchResults.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
				| System.Windows.Forms.AnchorStyles.Left)
				| System.Windows.Forms.AnchorStyles.Right)));
			this.SearchResults.FullRowSelect = true;
			this.SearchResults.GridLines = true;
			this.SearchResults.HideSelection = false;
			this.SearchResults.Location = new System.Drawing.Point(8, 112);
			this.SearchResults.MultiSelect = false;
			this.SearchResults.Name = "SearchResults";
			this.SearchResults.Size = new System.Drawing.Size(496, 248);
			this.SearchResults.TabIndex = 17;
			this.SearchResults.View = System.Windows.Forms.View.Details;
			this.SearchResults.ItemActivate += new System.EventHandler(this.SearchResults_ItemActivate);
			// 
			// Criteria
			// 
			this.Criteria.Location = new System.Drawing.Point(80, 64);
			this.Criteria.Name = "Criteria";
			this.Criteria.Size = new System.Drawing.Size(152, 22);
			this.Criteria.TabIndex = 16;
			this.Criteria.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 16);
			this.label1.TabIndex = 13;
			this.label1.Text = "Search by:";
			// 
			// SearchFields
			// 
			this.SearchFields.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.SearchFields.Location = new System.Drawing.Point(80, 8);
			this.SearchFields.Name = "SearchFields";
			this.SearchFields.Size = new System.Drawing.Size(152, 24);
			this.SearchFields.TabIndex = 23;
			this.SearchFields.SelectedIndexChanged += new System.EventHandler(this.SearchFields_SelectedIndexChanged);
			// 
			// btnRun
			// 
			this.btnRun.Location = new System.Drawing.Point(288, 64);
			this.btnRun.Name = "btnRun";
			this.btnRun.Size = new System.Drawing.Size(96, 32);
			this.btnRun.TabIndex = 24;
			this.btnRun.Text = "Run Search";
			this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
			// 
			// lblOrder
			// 
			this.lblOrder.Location = new System.Drawing.Point(240, 8);
			this.lblOrder.Name = "lblOrder";
			this.lblOrder.Size = new System.Drawing.Size(48, 32);
			this.lblOrder.TabIndex = 25;
			this.lblOrder.Text = "Sort Order:";
			// 
			// Ascending
			// 
			this.Ascending.Checked = true;
			this.Ascending.Location = new System.Drawing.Point(288, 8);
			this.Ascending.Name = "Ascending";
			this.Ascending.Size = new System.Drawing.Size(88, 19);
			this.Ascending.TabIndex = 26;
			this.Ascending.TabStop = true;
			this.Ascending.Text = "Ascending";
			// 
			// Descending
			// 
			this.Descending.Location = new System.Drawing.Point(288, 32);
			this.Descending.Name = "Descending";
			this.Descending.Size = new System.Drawing.Size(104, 19);
			this.Descending.TabIndex = 27;
			this.Descending.Text = "Desscending";
			// 
			// btnApply
			// 
			this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.btnApply.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnApply.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnApply.Image = ((System.Drawing.Image)(resources.GetObject("btnApply.Image")));
			this.btnApply.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
			this.btnApply.Location = new System.Drawing.Point(264, 369);
			this.btnApply.Name = "btnApply";
			this.btnApply.Size = new System.Drawing.Size(80, 23);
			this.btnApply.TabIndex = 28;
			this.btnApply.Text = "&Apply";
			this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
			// 
			// FormSearchBase
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
			this.ClientSize = new System.Drawing.Size(512, 398);
			this.Controls.Add(this.btnApply);
			this.Controls.Add(this.Descending);
			this.Controls.Add(this.Ascending);
			this.Controls.Add(this.Criteria);
			this.Controls.Add(this.lblOrder);
			this.Controls.Add(this.btnRun);
			this.Controls.Add(this.SearchFields);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.SearchResults);
			this.Controls.Add(this.label1);
			this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.KeyPreview = true;
			this.Name = "FormSearchBase";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "FormSearchBase";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.FormSearchBase_Closing);
			this.ResumeLayout(false);

		}
		#endregion

		private void SearchFields_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if (Controller != null)
				Controller.SearchFieldsChanged(sender, e);
		}

		private void SearchResults_ItemActivate(object sender, System.EventArgs e)
		{
			if (Controller != null)
				Controller.Accept(sender, e);
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			if (Controller != null)
				Controller.Cancel(sender, e);
		}

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			if (Controller != null)
				Controller.Accept(sender, e);
		}

		private void FormSearchBase_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if (Controller != null)
				Controller.Closing(sender, e);
		}

		private void btnRun_Click(object sender, System.EventArgs e)
		{
			if (Controller != null)
				Controller.RunSearch(sender, e);
		}

		private void btnApply_Click(object sender, System.EventArgs e)
		{
			if (Controller != null)
				Controller.GenericAction(sender, e);
		}


	}
}
